package org.example.modules.user.controller;

import com.alibaba.fastjson2.JSONObject;
import org.example.modules.user.common.Commsult;
import org.example.modules.user.entry.Review;
import org.example.modules.user.service.ReviewService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Description ReviewController
 * @Author xiaotian
 * @Date 2025-04-21
 */
@RestController
@RequestMapping("/wxApi/review")
public class ReviewController {

    @Autowired
    private ReviewService reviewService;

    // 获取评论列表
    @GetMapping("/list/{sideJobId}")
    public Commsult<List<Review>> getReviews(@PathVariable String sideJobId) {
        List<Review> reviews = reviewService.getReviewsBySideJobId(sideJobId);
        return Commsult.success(reviews);
    }
    @GetMapping("/list1/{sideJobId}")
    public Commsult<List<Review>> getReviews1(@PathVariable String sideJobId) {
        List<Review> reviews = reviewService.getReviewsBySideJobId1(sideJobId);
        return Commsult.success(reviews);
    }

    // 提交评论
    @PostMapping("/submit")
    public Commsult submitReview(@RequestBody JSONObject request) {
        reviewService.submitReview(request);
        return Commsult.success("评论成功");
    }
    @PostMapping("/updateStatus")
    public Commsult<List<Review>> updateStatus(@RequestBody JSONObject request) {

        return Commsult.success(reviewService.updateReview(request));
    }
}